var taskPage = avalon.define({
	$id: "taskPage",
	id: "",
	uid: "",
	companyName: "",
	channel:"",
	inShort: "",
	taxNo: "",
	companyType: "",
	email: "",
	region: "",
	country: "",
	state: "",
	city: "",
	status: 0,
	detailAddress: "",
	contact: "",
	jobTitle: "",
	telCode: "",
	telNo: "",
	existingDistributor: "",
	preferredDistributor: "",
	companySize: "",
	companyWebsite: "",
	aapisr: "",
	remark: "",
	approve: function() {
		mui.ajax('/task/approve.do', {
			data: {
				tid: taskPage.id,
				uid:taskPage.uid
			},
			dataType: 'json',
			success: function(data) {
				mui.alert('', data.msg, function() {
					mui.openWindow({
						url: "list.html"
					});
				});
			}
		});
	},
	reject: function() {
		mui.ajax('/task/reject.do', {
			data: {
				tid: taskPage.id,
				uid:taskPage.uid
			},
			dataType: 'json',
			success: function(data) {
				mui.alert('', data.msg, function() {
					mui.openWindow({
						url: "list.html"
					});
				});
			}
		});
	}
});

mui.ready(function() {
	//当前登入人的基本信息
	var uid = $("#uid").val();
	taskPage.uid = uid;

	//要被审核的用户信息
	var tid = $.getParameter("tid");
	taskPage.id=tid;
	
	mui.ajax('/customer/get.json', {
		data: {
			uid: taskPage.id
		},
		dataType: 'json',
		success: function(data) {
			taskPage.companyName = data.companyName;
			if(data.channel==1) {
				taskPage.channel = 'APP';
			};
			if(data.channel==2) {
				taskPage.channel = 'Official';
			}
			taskPage.inShort = data.inshort;
			taskPage.taxNo = data.taxNo;
			taskPage.companyType = data.companyType;
			taskPage.email = data.email;
			taskPage.detailAddress = data.detailAddress;
			taskPage.contact = data.contact;
			taskPage.jobTitle = data.jobTitle;
			taskPage.telNo = data.telNo;
			taskPage.existingDistributor = data.existingDistributor;
			taskPage.preferredDistributor = data.preferredDistributor;
			taskPage.companySize = data.companySize;
			taskPage.companyWebsite = data.companyWebSite;
			taskPage.aapisr = data.aapisr;
			taskPage.remark = data.remark;
			taskPage.telCode = data.telCode;
			taskPage.status = data.status;
			taskPage.id = data.id;
			

			if(null != data.regionLocation) {
				taskPage.region = data.regionLocation.name;
			}
			if(null != data.countryLocation) {
				taskPage.country = data.countryLocation.name;
			}
			if(null != data.stateLocation) {
				taskPage.state = data.stateLocation.name;
			}
			if(null != data.city) {
				taskPage.city = data.city;
			}

		}
	});

});